package cn.tedu._03vehicle.pojo.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

@Data
public class UserRegParam {
    //@NotNull(message = "用户名不能为null")
    //@NotEmpty(message = "用户名不能为空和null")
    //@Range(min = 1,max = 7,message = "用户名长度需为1-7个字符")
    @Pattern(
            regexp = "^[\u4e00-\u9fa5]{1,7}$|^[a-zA-Z]{1,14}$",
            message = "用户名需为1-7个纯汉字或1-14个纯英文"
    )
    @Schema(description = "用户名",required= true)
    private String username;
    @Pattern(
            regexp = "^(?:(?=.*[a-zA-Z])(?=.*\\d)|(?=.*[a-zA-Z])(?=.*\\p{Punct})|(?=.*\\d)(?=.*\\p{Punct}))[a-zA-Z0-9\\p{Punct}]{8,14}$",
            message = "密码需8-14个字符，包含字母、数字、标点中的至少2种，且不能有空格和中文"
    )
    @Schema(description = "密码",required= true)
    private String password;
    @Pattern(
            // 正则表达式：覆盖绝大多数常见邮箱格式
            regexp = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
            message = "邮箱格式不正确（示例：xxx@xxx.com）"
    )
    @Schema(description = "邮箱",required= true)
    private String email;
    @Pattern(
            // 正则表达式：严格匹配11位手机号规则
            regexp = "^1[3-9]\\d{9}$",
            message = "手机号格式不正确（应为11位数字，以1开头，第二位为3-9）"
    )
    @Schema(description = "手机号码",required= true)
    private String phone;
}
